package com.talent.codes.model;

public class GasLabel {
    protected String name;
    protected String title;
    protected String webSite;

    protected int width=240;
    protected int height=240;

    protected EleStyle titleStyle= new EleStyle("宋体", 42).style(1.0f, 50);
    protected EleStyle barCodeStyle = new EleStyle("宋体", 34);

    protected ElePos titlePos = new ElePos(4,20, 110, 110);
    protected ElePos qrCodePos = new ElePos(112, 4, 138, 138);
    protected ElePos barCodePos = new ElePos(-10, 144, 260, 65);

    public GasLabel() {
    }

    public GasLabel(String title, String webSite) {
        this(title, webSite, 240, 240);
    }

    public GasLabel(String title, String webSite, int width, int height) {
        this.name = title == null ? "" : (title.length()>6 ? title.substring(0, 6) : title);
        this.title = this.name;
        this.webSite = webSite;

        this.width = width;
        this.height = height;

        initTitleStyle();
    }

    protected void initTitleStyle(){
        int len = title.length();
        this.titleStyle = new EleStyle("宋体", 42).style(1.0f, 50);
        if(len<4){
            // 一行展示, 可以自己想办法扩充至 3字符
            this.titleStyle.style(1.0f, this.titlePos.getHeight());
        }else if(len==4){
            //两行展示
            this.titleStyle.style(1.0f, this.titlePos.getHeight()/2);
        }else{
            this.titleStyle.style(.8f, this.titlePos.getHeight()/2);
        }
    }

    public GasLabel titleStyle(String fontName, int fontSize){
        this.titleStyle.setFontName(fontName);
        this.titleStyle.setFontSize(fontSize);
        return this;
    }
    public GasLabel titleStyle(String fontName, int fontSize, float space, int lineHeight){
        this.titleStyle.setFontName(fontName);
        this.titleStyle.setFontSize(fontSize);
        this.titleStyle.style(space, lineHeight);
        return this;
    }



    public GasLabel size(int width, int height) {
        this.width = width;
        this.height = height;
        return this;
    }

    public GasLabel titlePos(int x, int y, int width, int height) {
        this.titlePos = new ElePos(x, y, width, height);
        initTitleStyle();
        return this;
    }

    public GasLabel qrCodePos(int x, int y, int width, int height) {
        this.qrCodePos = new ElePos(x, y, width, height);
        return this;
    }
    public GasLabel barCodePos(int x, int y, int width, int height) {
        this.barCodePos = new ElePos(x, y, width, height);
        return this;
    }

    public GasLabel barCodeStyle(String fontName, int fontSize) {
        this.barCodeStyle.setFontName(fontName);
        this.barCodeStyle.setFontSize(fontSize);
        return this;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getWebSite() {
        return webSite;
    }

    public void setWebSite(String webSite) {
        this.webSite = webSite;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public EleStyle getTitleStyle() {
        return titleStyle;
    }

    public void setTitleStyle(EleStyle titleStyle) {
        this.titleStyle = titleStyle;
    }

    public EleStyle getBarCodeStyle() {
        return barCodeStyle;
    }

    public void setBarCodeStyle(EleStyle barCodeStyle) {
        this.barCodeStyle = barCodeStyle;
    }

    public ElePos getTitlePos() {
        return titlePos;
    }

    public void setTitlePos(ElePos titlePos) {
        this.titlePos = titlePos;
    }

    public ElePos getQrCodePos() {
        return qrCodePos;
    }

    public void setQrCodePos(ElePos qrCodePos) {
        this.qrCodePos = qrCodePos;
    }

    public ElePos getBarCodePos() {
        return barCodePos;
    }

    public void setBarCodePos(ElePos barCodePos) {
        this.barCodePos = barCodePos;
    }

}
